package com.ld.wms.business.material.controller;


import com.ld.wms.business.material.service.MaterialExampleInventoryService;
import com.ld.wms.business.material.vo.req.MaterialExampleInventoryReqVo;

import com.ld.wms.business.material.vo.resp.MaterialExampleInventoryRespVo;
import com.ld.wms.common.ResultResponse;
import com.ld.wms.common.vo.GeneratePageListVo;
import com.ld.wms.sysenum.ResultResponseEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 物料库存扩展详细信息 前端控制器
 * </p>
 *
 * @author wangfeng
 * @since 2025-02-24
 */
@Slf4j
@Tag(name = "物料实例库存信息相关接口")
@RestController
public class MaterialExampleInventoryController {

    @Autowired
    private MaterialExampleInventoryService materialExampleInventoryService;

    @GetMapping("/api/wms/materialExampleInventory/getPageList")
    @Operation(summary = "物料管理-物料库存列表(查询所有size传9999)")
    public ResultResponse<GeneratePageListVo<MaterialExampleInventoryRespVo>> getPageList(
            @Parameter(description = "物料实例id") @RequestParam(required = false) Long materialExampleId,
            @Parameter(description = "抽屉孔位id") @RequestParam(required = false) Long lockerGridHoleId,
            @RequestParam(required = false, defaultValue = "1") Integer current,
            @RequestParam(required = false, defaultValue = "10") Integer size
    ) {
        GeneratePageListVo<MaterialExampleInventoryRespVo> allList = materialExampleInventoryService.getPageList(materialExampleId, lockerGridHoleId, current, size);
        return ResultResponse.success(allList);
    }

    @GetMapping("/api/wms/materialExampleInventory/getById")
    @Operation(summary = "详情")
    public ResultResponse<MaterialExampleInventoryReqVo> getById(
            @RequestParam Long id
    ) {
        MaterialExampleInventoryReqVo byId = materialExampleInventoryService.getDetails(id);
        return ResultResponse.success(byId);
    }

    @PostMapping("/api/wms/materialExampleInventory/add")
    @Operation(summary = "添加")
    public ResultResponse<ResultResponseEnum> add(
            @RequestBody MaterialExampleInventoryReqVo reqVo
    ) {
        materialExampleInventoryService.add(reqVo);
        return ResultResponse.success();
    }

    @PostMapping("/api/wms/materialExampleInventory/update")
    @Operation(summary = "修改")
    public ResultResponse<ResultResponseEnum> updateById(
            @RequestBody MaterialExampleInventoryReqVo reqVo
    ) {
        materialExampleInventoryService.updateById(reqVo);
        return ResultResponse.success();
    }

}

